<div id="contact-form" style="display: none">

    <p class="contactvalidateTips">All form fields are required.</p>
    <form id="contactform" enctype="application/x-www-form-urlencoded" method="post" action="">
        <fieldset style="padding: 0; border: 0; margin-top: 25px;">
            <label for="conName" class="label required">Name</label>
            <input type="text" name="conName" id="conName" value="" />
            <label for="conEmail" class="label required">Email</label>
            <input type="text" name="conEmail" id="conEmail" value="" />
            <label for="conSubject" class="label required">Subject</label>
            <input type="text" name="conSubject" id="conSubject" value="" />
            <label for="conContent" class="label optional">Content</label>
            <textarea name="conContent" id="conContent" style="width: 300px; height: 200px" rows="24" cols="80"></textarea>
        </fieldset>
    </form>
</div>
<script type="text/javascript">
    <!-- 
    $(document).ready(function(){
        $("#contact-form").attr('title', 'Send email to Admin');
        $("#contact-form").dialog({
            autoOpen: false,
            height: 450,
            width: 350,
            modal: true,
            buttons: {
                "Send": function() {
                    var bValid = true;
                    allFields.removeClass( "ui-state-error" );

                    bValid = bValid && checkLength( conemail, "email", 8, 64 );
                    // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
                    bValid = bValid && checkRegexp( conemail, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. username@fsoft.com.vn" );

                    if ( bValid ) {
                        $.ajax({
                            type: "POST",
                            url: "/QLTSv1/front/mail/send",
                            data: "Name="+conname.val()+"&Email="+conemail.val()+"&Subject="+consubject.val()+"&Content="+concontent.val(),
                            success: function (data){
                                alert(data);
                                var getData = $.parseJSON(data);
                                var tag = $("<div title='"+getData.status+"'></div>");
                                tag.html("<span>"+getData.msg+"</span>").dialog({
                                    resizable: false,
                                    height:200,
                                    width: 300,
                                    modal: true,
                                    buttons: {
                                        "OK": function() {
                                            $( this ).dialog( "close" );
                                        }
                                    }
                                }).dialog("open");
                            }
                        });
                        $( this ).dialog( "close" );      
                    }
                                            
                },
                Cancel: function() {
                    $( this ).dialog( "close" );
                    window.location = '/QLTSv1/';
                }
            },
            close: function() {
                allFields.val( "" ).removeClass( "ui-state-error" );
                window.location = '/QLTSv1/';
            }
        });
        $( "#contact-form" ).dialog( "open" );
        //////////////////////////////////
        var tips = $(".convalidateTips");
        var conname = $("#conName"),
        conemail = $("#conEmail"),
        consubject = $("#conSubject"),
        concontent = $("#conContent"),
        allFields = $( [] ).add(conname).add(conemail).add(consubject).add(concontent);
                            
        function updateTips( t ) {
            tips
            .text( t )
            .addClass( "ui-state-highlight" );
            setTimeout(function() {
                tips.removeClass( "ui-state-highlight", 1500 );
            }, 500 );
        }

        function checkLength( o, n, min, max ) {
            if ( o.val().length > max || o.val().length < min ) {
                o.addClass( "ui-state-error" );
                updateTips( "Length of " + n + " must be between " +
                    min + " and " + max + "." );
                return false;
            } else {
                return true;
            }
        }

        function checkRegexp( o, regexp, n ) {
            if ( !( regexp.test( o.val() ) ) ) {
                o.addClass( "ui-state-error" );
                updateTips( n );
                return false;
            } else {
                return true;
            }
        }
    });
    -->
</script>